package other;

import java.util.Scanner;

public class Main {
    /**
     * 给定一个8位字符串的年月日格式的日期(yyyyMMdd)，计算日期为所在年份的第几天
     */
    public static void main(String[] args) {
        int[] arr = {31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        Scanner input = new Scanner(System.in);
        System.out.println("请输入(格式yyyyMMdd)");
        int date = input.nextInt();
        int year = date / 10000;
        int moth = date / 100 % 100;
        int sum = 0;
        int day = date % 100;
        // 闰年
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            arr[2] = 29;
        }
        for (int i = 2; i <= moth; i++) {
            sum += arr[i];
        }
        int total = sum + day;
        System.out.println("这是" + year + "年的第" + total + "天");

    }
}
